package Java7_Concurrency_Cookbook.concurrent_custom.custom_priority_transfer_queue;

/**
 * @author lixiangke
 * @date 2017/11/28
 */
public class Consumer implements Runnable {
    MyPriorityTransferQueue<Event> buffer;

    public Consumer(MyPriorityTransferQueue buffer) {
        this.buffer = buffer;
    }

    @Override
    public void run() {
        for (int i = 0; i < 1002; i++) {
            try {
                Event value = buffer.take();
                System.out.printf("Consumer: %s : %d \n", value.getThread(), value.getPriority());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }


        }
    }
}
